package com.jumi.microservice.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jumi.microservice.constant.StatusEnum;
import com.jumi.microservice.domain.ExpressDO;
import com.jumi.microservice.domain.ExpressDTO;
import com.jumi.microservice.domain.ExpressDataDTO;
import com.jumi.microservice.mapper.ExpressMapper;
import com.jumi.microservice.service.BasicDataApi;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * - - - - - - - - - - - - - - -
 * 基础资料对外实现
 * @author liuz
 * @date 2020/9/2 10:44
 * ToDoSomeThing
 * - - - - - - - - - - - - - - -
 */
@Service
public class BasicDataService implements BasicDataApi {

    @Autowired
    private ExpressMapper expressMapper;

    /**
     * 获取快递公司信息
     * @return
     */
    @Override
    public List<ExpressDataDTO> selectExpressList() {
        List<ExpressDO> list = expressMapper.selectList(new QueryWrapper<>());
        return list.stream().map(e->{
            ExpressDataDTO dto = new ExpressDataDTO();
            dto.setId(e.getId());
            dto.setExpressName(e.getExpressName());
            dto.setExpressCode(e.getExpressCode());
            dto.setStatus(e.getStatus());
            dto.setIsDel(e.getIsDel());
            return dto;
        }).collect(Collectors.toList());
    }
}
